<template>
	<!-- 添加弹框 -->
	<el-dialog width="900px" title="" visible :show-close="false" :modal-append-to-body="false" class="wrap" @close="cancel" :close-on-click-modal="false">
		<i class="el-icon-close close" @click="cancel" style="color: white;"></i>
		<div class="bt">{{vtitle}}</div>
		<el-form label-width="100px" class="form">
			<div class="top" style="width: 100%;float: left;">
				<div class="left" style="width: 50%;float: left;">
					<el-form-item label="课程名称">
						<el-select v-model="vkcid" placeholder="请选择课程" class="select-block1">
							<el-option :label="v.mc" :value="v.id+''" v-for="v in xzkclist"></el-option>
						</el-select>
					</el-form-item>
					<el-form-item label="班级名称">
						<el-input v-model="vbjmc" placeholder="请输入班级名称" icon="add" class="select-block1"></el-input>
						<!-- <el-button size="small" @click="bj" class="select-block2" >。。</el-button> -->
					</el-form-item>
					<el-form-item label="老师名称">
						<el-select v-model="vlsid" placeholder="请选择老师" class="select-block1">
							<el-option :label="v.zwm" :value="v.id" v-for="v in comboxlist"></el-option>
						</el-select>
					</el-form-item>
				</div>
				<div class="right" style="width: 50%;float: right;">
					<el-form-item label="教材名称">
						<!-- :readonly="true" -->
						<el-input v-model="vjcmc" placeholder="请选择教材名称 " disabled class="select-block" icon="add"></el-input>
						<el-button size="small" @click="showwp()" class="select-block2">选择</el-button>
					</el-form-item>
					<el-form-item label="行政老师">
						<el-select v-model="xzls" placeholder="请选择行政老师" class="select-block1">
							<el-option :label="v.zwm" :value="v.id" v-for="v in xzlsList"></el-option>
						</el-select>
					</el-form-item>

					<el-form-item label="开班日期">
						<el-date-picker v-model="vbtime" type="date" :editable="false"   class="select-block1" placeholder="选择日期" @keyup.enter.native="search"> </el-date-picker>
					</el-form-item>
				</div>
			</div>

			<el-button type="primary" class="submit" @click="submit">保存</el-button>
			<el-button type="danger" class="submit" @click="cancel" style="margin-left: 10px;">退出</el-button>
		</el-form>

		<PayArticle class="wpfl1" @jcarticle="jcarticleed" @close="jcarticlecancel" v-if="showarticle"></PayArticle>
		<Kschoose class="wpfl" :params="this.vkcid" @wpchoose="wpchooseed" @close="wpchoosecancel" v-if="showchoselist"></Kschoose>
		<!-- <el-dialog  width="60%" title=""    visible :show-close="true" :append-to-body="true"   :close-on-click-modal="false"> -->
		<Lskb class="lskb" @close="lskbcancel" v-if="showlskblist" :params="vlsid"></Lskb>
		<Jskb class="lskb" @close="jskbcancel" v-if="showjskblist" :params="vjsid"></Jskb>
		<Jslskb class="lskb" @close="jslskbcancel" v-if="showjslskblist" :params="this.form"></Jslskb>

		<!-- </el-dialog> -->
	</el-dialog>
</template>
<script type="text/javascript">
	import Kschoose from '../../manage/kssz/kschoose'
	import Lskb from './kebiao/lskb'
	import Jskb from './kebiao/jskb'
	import PayArticle from './pay-articlejc'
	import Jslskb from './kebiao/jslskb'
	import qs from 'qs'
	export default {
		props: ['params'],
		components: {
			Kschoose,
			PayArticle,
			Lskb,
			Jskb,
			Jslskb
		},
		data() {
			return {
				vifys:'N',
				check: true,
				vbjlx: 'N',
				vtitle: '班级新增',
				showchoselist: false,
				showlskblist: false,
				showjskblist: false,
				showarticle: false,
				showjslskblist: false,
				vfxkcid: '',
				vjsid: '',
				jsboxlist: [],
				sjdboxlist: [],
				vkssl: '',
				vfxkcidmc: '',
				vbjmc: '',
				vbtime: '',
				vlsid: '',
				vcid: '',
				vjcid: '',
				vjcmc: '',
				vlx: '',
				vypks: '',
				xzls: '',
				comboxlist: [],
				dialogTableVisible: true,
				xzlsList: [],
				xzkclist: [],
				vkcid: '',
				ddd: [{
					id: 1,
					ischecked: false
				}]
			}
		},
		created() {
			this.vbjlx = this.params.bjlx;
			if(this.vbjlx == 'Y') {
				this.vtitle = '班级新增';
			} else if(this.vbjlx == 'N') {
				this.vtitle = '预设班级新增';
			}
			this.getcomboxlist();
			this.getxzlsList();
			this.getxzkclist();
			this.getjslist();
		},
		methods: {
			bj() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				var params2 = qs.stringify({
					xxid: logininfo.xxid,
					yhid: logininfo.id,
					kcid: this.vfxkcid
				})
				//执行
				this.axios.post(this.$store.state.api + 'bj/zdgetbjmc', params2)
					.then(res => {
						this.vbjmc = res.data.data.list[0].bjmc;
						this.searchLoading = false;
					}).catch(res => {})

			},
			jslskb() {
				this.showjslskblist = true;
			},
			jslskbcancel(setting) {

				this.showjslskblist = false;
			},
			getjslist() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				var params2 = qs.stringify({
					keyword: this.vkeyword, // keyword
					isenable: this.visenable,
					yhid: logininfo.id,
					xxid: logininfo.xxid,
					pageindex: this.pageindex,
					pagesize: this.pagesize
				})
				//执行
				this.axios.post(this.$store.state.api + 'xxjs/mc', params2)
					.then(res => {
						let data = res.data.data;
						this.jsboxlist = data;
					}).catch(res => {})
			},
			getsjdlist() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				var params2 = qs.stringify({
					jsid: this.vjsid
				})
				//执行
				this.axios.post(this.$store.state.api + 'jssjd/mc', params2)
					.then(res => {
						let data = res.data.data;
						this.sjdboxlist = data;
					}).catch(res => {})
			},
			getxzlsList() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				var params2 = qs.stringify({
					xxid: logininfo.xxid
				})
				//执行
				this.axios.post(this.$store.state.api + 'ls/mc', params2)
					.then(res => {
						let data = res.data.data;
						let list = data;
						this.xzlsList = list;
					}).catch(res => {
						this.searchLoading = false;
					})
			},
			getxzkclist() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				var params2 = qs.stringify({
					yhid: logininfo.id,
					xxid: logininfo.xxid
				})
				//执行
				this.axios.post(this.$store.state.api + 'kcfl/getfllist', params2)
					.then(res => {
						this.xzkclist = res.data.data.list;
					}).catch(res => {
					})
			},
			submit() {

				//检测
				 if(!this.vbjmc) {
				 	this.$message.warning('请输入班级名称');
				 	this.$store.state.loading = false;
				 	return;
				 }
				 if(!this.vkcid) {
				 	this.$message.warning('请选择课程');
				 	this.$store.state.loading = false;
				 	return;
				 }
				 if(!this.vjcmc) {
				 	this.$message.warning('请选择教材');
				 	this.$store.state.loading = false;
				 	return;
				 }
				 if(!this.vlsid) {
				 	this.$message.warning('请选择老师');
				 	this.$store.state.loading = false;
				 	return;
				 }
				 if(!this.xzls) {
				 	this.$message.warning('请选择行政老师');
				 	this.$store.state.loading = false;
				 	return;
				 }
				 if(!this.vbtime) {
				 	this.$message.warning('请选择开班时间');
				 	this.$store.state.loading = false;
				 	return;
				 }
				var time1 = this.$.getLocalTimeNo0(Date.parse(this.vbtime));
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					mc: this.vbjmc,
					xzid: this.xzls,
					fxkcid: this.vkcid,
					yhid: logininfo.id,
					xxid: logininfo.xxid,
					jcid: this.vjcid,
					lsid: this.vlsid,
					kbrq: time1,
					kscnt: this.vkssl,
					ifys:this.vifys

					// jsid:this.vjsid,
					// sjdid:hstr,
					// cid:this.vcid,
					// ifys:this.vbjlx,

				});
				//执行
				this.axios.post(this.$store.state.api + 'bj/insertbj', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', {type: 'add',cancel: false});
							this.$message.success(res.data.msg);
							this.$store.state.loading = false;
						} else {
							this.showjslskblist = true;
							this.$message.warning(res.data.msg);
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.danger("服务器繁忙，请重试");
						this.$store.state.loading = false;
					})
			},
			lskb() {
				this.showlskblist = true;
			},
			jskb() {
				this.showjskblist = true;
			},
			showwp() {
				this.showchoselist = true;
			},
			showjc() {
				this.showarticle = true;
			},
			wpchooseed(josndata) {
				console.log(josndata, 'wzwZ');
				this.vfxkcidmc = josndata.kcmc;
				this.vfxkcid = josndata.fxkcid;
				this.vkssl = josndata.kssl;

				this.showchoselist = false;
			},
			jcarticleed(josndata) {
				this.vcid = josndata.cid;
				this.vjcid = josndata.jcid;
				this.vjcidmc = josndata.jcidmc;
				this.showarticle = false;
			},
			wpchoosecancel(setting) {
				if(setting.cancel == false) {
					this.vjcmc = setting.data[0].mc;
					this.vjcid = setting.data[0].id;
					// this.vfxkcid = setting.data[0].id;
					// this.vfxkcidmc = setting.data[0].mc;
					// this.vjcidmc = setting.data[0].cmc;
					// this.vjcid = setting.data[0].jcid;
					// this.vcid = setting.data[0].cid;
					// this.vkssl = setting.data[0].number;

				}
				this.showchoselist = false;
			},
			lskbcancel(setting) {
				// alert(11)
				// console.log()
				// if(setting.cancel == false){
				// 	this.vfxkcid = setting.data[0].id;
				// 	this.vfxkcidmc = setting.data[0].mc;
				// 	this.vkssl = setting.data[0].number;
				// }
				this.showlskblist = false;
			},
			jskbcancel(setting) {
				// alert(11)
				// console.log()
				// if(setting.cancel == false){
				// 	this.vfxkcid = setting.data[0].id;
				// 	this.vfxkcidmc = setting.data[0].mc;
				// 	this.vkssl = setting.data[0].number;
				// }
				this.showjskblist = false;
			},
			jcarticlecancel() {
				this.showarticle = false;
			},
			cancel() {
				this.$emit('close', {
					type: 'add',
					cancel: true
				})
			},
			getcomboxlist() {
				var logininfo = JSON.parse(localStorage.logininfo);
				this.searchLoading = true;
				var params2 = qs.stringify({
					xxid: logininfo.xxid
				})
				//执行
				this.axios.post(this.$store.state.api + 'ls/mc', params2)
					.then(res => {
						let data = res.data.data;
						let list = data;
						this.comboxlist = list;
					}).catch(res => {
						this.searchLoading = false;
					})
			}
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		.row {
			height: 50px;
			line-height: 50px;
		}
		.bt {
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top: 0;
			left: 0;
			// margin-top: -70px;
			background: #50BFFF;
			// margin-left: -20px;
			// margin-bottom: 20px;
			color: white;
			text-align: left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.close {
			z-index: 10;
			position: absolute;
		}
		.input-block {
			margin-bottom: 20px;
			text-align: center;
		}
		.input {
			width: 280px;
			display: inline-block;
			margin-left: 10px;
		}
		.input1 {
			width: 210px;
			display: inline-block;
			margin-left: 10px;
		}
		.input-block span {
			display: inline-block;
			width: 70px;
			text-align: right;
		}
		.submit {
			width: 120px;
			margin-left: 35%;
		}
		.wpfl {
			// background: red;
			// position: absolute;
			// top: 20%;
			// left: -10%;
		}
		.lskb {
			width: 143.5%;
			background: #fff;
			position: absolute;
			top: -100px;
			left: -22%;
			z-index: 50;
			padding-bottom: 100px;
		}
		.wpfl1 {
			width: 130%;
			background: #fff;
			position: absolute;
			top: 5px;
			left: -66px;
		}
		.form {
			overflow: hidden;
			text-align: left;
			margin-top: 20px;
			.select-block {
				width: 50%;
				// display: block;
			}
			.select-block1 {
				width: 68%;
				// display: block;
			}
			.weekdiv {
				width: 100%;
				height: 100%;
				margin: 0 auto;
				background: lightblue;
			}
			.wdiv0 {
				line-height: 45px;
				width: 100px;
				margin-left: 20%;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv1 {
				width: 40px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv2 {
				width: 40px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv3 {
				width: 40px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv4 {
				width: 40px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv5 {
				width: 40px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv6 {
				width: 40px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.wdiv7 {
				width: 40px;
				float: left;
				background: lightgoldenrodyellow;
			}
			.el-checkbox+.el-checkbox {
				margin-left: 0px;
			}
		}
	}
</style>